package com.gugee.ins.data.task.media;

import com.gugee.common.task.dto.TaskParam;
import com.gugee.ins.data.task.constant.TaskType;
import com.gugee.ins.data.task.media.service.*;
import com.xiguaji.boot.toolkit.JsonUtil;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 大博主帖子、评论采集任务
 * @author Huangxin
 */
@Component
@Slf4j
public class InsMediaTask {

    /**
     *
     */
    @Autowired
    public InsMediaCollectSvc insMediaCollectSvc;

    /**
     *
     */
    @Autowired
    public InsCommentCollectSvc insCommentCollectSvc;

    /**
     *
     */
    @Autowired
    public InsAdMediaIdentifySvc insAdMediaIdentifySvc;

    /**
     *
     */
    @Autowired
    public InsMiddleBloggerMediaCollectSvc insMiddleBloggerMediaCollectSvc;

    @Autowired
    public InsBrandMediaRelSvc insBrandMediaRelSvc;


    /**
     * 大播主采集帖子信息发送
     * @param param  {"records":2000,"pagesLimit":10000}
     *                  records:一页最多的记录数
     *                   pagesLimit：发送最大页数
     * @return 调度结果
     */
    @XxlJob("sendMBloggerMsg4MediaCl")
    public ReturnT<String> sendMBloggerMsg4MediaCl(String param) {
        TaskParam taskParam = JsonUtil.jsonParse(TaskParam.class, param);
        return insMediaCollectSvc.xxlJobStart(TaskType.INS_MEDIA_CL.getValue(),"sendMBloggerMsg4MediaCl",taskParam,false);
    }

    /**
     * 大播主采集评论信息发送
     * @param param  {"records":2000,"pagesLimit":10000}
     *                  records:一次最多的收录的记录数
     *                   pagesLimit：发送最大页数
     * @return 调度结果
     */
    @XxlJob("sendMBloggerMsg4CommentCl")
    public ReturnT<String> sendMBloggerMsg4CommentCl(String param) {
        TaskParam taskParam = JsonUtil.jsonParse(TaskParam.class, param);
        return insCommentCollectSvc.xxlJobStart(TaskType.INS_COMMENT_CL.getValue(),"sendMBloggerMsg4CommentCl",taskParam,false);
    }

    /**
     * 大播主广告帖子识别信息发送
     * @param param  {"records":2000,"pagesLimit":10000}
     *                  records:一次最多的收录的记录数
     *                   pagesLimit：发送最大页数
     * @return 调度结果
     */
    @XxlJob("sendMBloggerMsg4AdMediaIdentify")
    public ReturnT<String> sendBloggerMsg4UpdateBaseInfo(String param) {
        TaskParam taskParam = JsonUtil.jsonParse(TaskParam.class, param);
        return insAdMediaIdentifySvc.xxlJobStart(TaskType.INS_AD_MEDIA_IDENTIFY.getValue(),"sendBloggerMsg4UpdateBaseInfo",taskParam,false);
    }

    /**
     * 中播主采集帖子信息发送
     * @param param  {"records":2000,"pagesLimit":10000}
     *                  records:一页最多的记录数
     *                   pagesLimit：发送最大页数
     * @return 调度结果
     */
    @XxlJob("sendMBloggerMsg4MiddleBloggerMediaCl")
    public ReturnT<String> sendMBloggerMsg4MiddleBloggerMediaCl(String param) {
        TaskParam taskParam = JsonUtil.jsonParse(TaskParam.class, param);
        return insMiddleBloggerMediaCollectSvc.xxlJobStart(TaskType.INS_MIDDLE_MEDIA_CL.getValue(),"sendMBloggerMsg4MiddleBloggerMediaCl",taskParam,false);
    }

    /**
     * 收集品牌的帖子信息
     * @param param
     * @return
     */
    @XxlJob("collectBrandMedia")
    public ReturnT<String> collectBrandMedia(String param) {
        return insBrandMediaRelSvc.xxlJobStart();
    }
}
